package com.zfei.serviceA;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class DemoController {

    @Autowired
    RestTemplate restTemplate;

    @GetMapping("test")
    String test(String a){
        try{
            MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
            param.add("a",1);
            param.add("b",2);
            param.add("key",a);
            return restTemplate.postForObject(
                    "http://serviceB/getObj",param, String.class);
        }catch (Exception e){
            e.printStackTrace();
        }
        return "";
    }
}
